﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OrderList.aspx.cs" Inherits="PersonInfo_OrderList" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="<%= ResolveUrl("~/jquery-easyui-1.2.6/themes/"+Skin+"/easyui.css") %>"
        rel="stylesheet" type="text/css" />
    <link href="../jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../Content/js/sysEasyUI.js" type="text/javascript"></script>
    <script type="text/javascript">
        var selectRow;
        $(function () {
            getData(0, 10);
        });
        function getData(pn, pz) {
            $('#grid').datagrid({
                nowrap: false,
                striped: true,
                singleSelect: true,
                collapsible: true,
                url: 'OrderList.aspx?para=GetList&startIndex=' + pn,
                sortName: 'ID',
                sortOrder: 'asc',
                idField: 'ID',
                height: 'auto',
                pageList: [5, 10, 20],
                pageSize: 20,
                fitColumns: true,
                columns: [[
        					
                            { field: 'Name', title: '姓名', width: 100, sortable: true },
                            { field: 'MEMBERNO', title: '会员卡号', width: 150 },
                            { field: 'Phone', title: '电话', width: 200 },
                            { field: 'ADDRESS', title: '收货地址', width: 250 },
                            { field: 'Post', title: '邮编', width: 250 },
                            { field: 'TRANSDATE', title: '下单时间', width: 200 },
                            { field: 'POINTS', title: '所用积分', width: 100 },
                            { field: 'STATUS', title: '状态', width: 100 }
        				]],
                pagination: true,
                rownumbers: true,
                onHeaderContextMenu: function (e, field) {
                    e.preventDefault();
                    if (!$('#tmenu').length) {
                        createColumnMenu("grid");
                    }
                    $('#tmenu').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                },
                onRowContextMenu: function (e, rowIndex, rowData) {
                    if ($.trim(rowData.ID) == "") {
                        var aa = $("#mm div");
                        for (var a = 0; a < aa.length; a++) {
                            var item = aa[a];
                            if (item.innerText == "修改" || item.innerText == "删除") {
                                $(item).css({ display: "none" });
                                $(item).parent().css({ display: "none" });
                            }
                        }
                    }
                    selectRow = rowData;
                    e.preventDefault();
                    $(this).datagrid('unselectAll');
                    $(this).datagrid('getRows', rowData.code);
                    $('#mm').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                }
            });
        }

        function Add() {
            openWindow("PersonEdit.aspx?para=add", 600, 400);
        }
        function Update() {
            openWindow("PersonEdit.aspx?para=update&id=" + selectRow.ID, 600, 400);
        }

        function Show() {
            openWindow("IntegralChangeList.aspx?id=" + selectRow.ID, 1000, 450);
        }

        function XQ() {
            openWindow("OrderMX.aspx?para=update&id=" + selectRow.ID, 600, 400);
        }

        function Delete() {
            $.messager.confirm("提示", "确定要发货吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        async: false,
                        url: "OrderList.aspx?para=delete&id=" + selectRow.ID,
                        success: function (data) {
                            if (data == "ok") {
                                alert("发货成功");
                                $("#grid").datagrid("reload");
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
            });
        }
        function Delete1() {
            $.messager.confirm("提示", "确定已备货吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        async: false,
                        url: "OrderList.aspx?para=delete1&id=" + selectRow.ID,
                        success: function (data) {
                            if (data == "ok") {
                                alert("备货成功");
                                $("#grid").datagrid("reload");
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
            });
        }
        function Delete2() {
            $.messager.confirm("提示", "确定已收货吗？", function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        async: false,
                        url: "OrderList.aspx?para=delete2&id=" + selectRow.ID,
                        success: function (data) {
                            if (data == "ok") {
                                alert("收货成功");
                                $("#grid").datagrid("reload");
                            }
                            else {
                                alert(data);
                            }
                        }
                    });
                }
            });
        }
        function btnSearch() {
            $("#Button1 ").click();
        }

       
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div style="display:none;">
        <table>
            <tr>
                <td>
                    订单起始日期:
                </td>
                <td>
                    <asp:TextBox ID="txtTime1" class="easyui-datebox" runat="server"></asp:TextBox>
                </td>
                <td>
                    订单截止日期:
                </td>
                <td>
                    <asp:TextBox ID="txtTime2" class="easyui-datebox" runat="server"></asp:TextBox>
                    <asp:Button ID="Button1" style="display:none;"  runat="server" Text="Button" 
                        onclick="Button1_Click" />
                </td>
                <td>会员卡号</td><td>
                <asp:TextBox ID="txtDZ" runat="server"></asp:TextBox>
                </td>
                <td>
                    会员姓名:
                </td>
                <td>
                    <asp:TextBox ID="txtJT" runat="server"></asp:TextBox>
                </td>
                <td rowspan="2">
                    <a class="easyui-linkbutton" onclick="btnSearch2()">查询</a>
                    <a class="easyui-linkbutton" onclick="btnSearch()">导出Excel</a>
                </td>
            </tr>
            <tr>
            <td>订单状态:</td>
            <td>
                <asp:DropDownList ID="DropDownList1" runat="server">
                    <asp:ListItem Value="0">全部</asp:ListItem>
                    <asp:ListItem Value="1">已下单</asp:ListItem>
                    <asp:ListItem Value="3">已备货</asp:ListItem>
                    <asp:ListItem Value="2">已发货</asp:ListItem>
                    <asp:ListItem Value="4">已收货</asp:ListItem>
                </asp:DropDownList>
                </td>
                <td>礼品所需积分:</td><td>
                    <asp:TextBox ID="txtJF" runat="server"></asp:TextBox>
                </td>
                <td>会员手机</td>
                <td>
                    <asp:TextBox ID="txtDY" runat="server"></asp:TextBox>
                </td>
                 <td>
                     所属品牌:
                </td>
                <td>
                    <asp:TextBox ID="txtMD" runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    <div>
        <table id="grid">
        </table>
        <div id="mm" class="easyui-menu" style="width: 120px;">
        <%--<div onclick="Delete1()" iconcls="icon-add">
                已备货</div>
            <div onclick="Delete()" iconcls="icon-add">
                已发货</div>--%>
                <div onclick="XQ()" iconcls="icon-add">
                详情</div>
        </div>
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    function btnSearch2() {

        $('#grid').datagrid('load', {
            time1:$("#txtTime1").datebox("getValue"),
            time2:$("#txtTime2").datebox("getValue"),
            text : $("#DropDownList1").val(),
            jf: $("#txtJF").val(),
             dz : $("#txtDZ").val(),
             dy: $("#txtDY").val(),
             jt: $("#txtJT").val(),
             md: $("#txtMD").val()
        });
//        var time1 = $("#txtTime1").datebox("getValue"); ;
//        var time2 = $("#txtTime2").datebox("getValue");
//        var obj = document.getElementById('DropDownList1');
//        var text = obj.options[obj.selectedIndex].value;
//        var jf = document.getElementById("txtJF").value;
//        var dz = $("#txtDZ").val();
//        var dy = $("#txtDY").val();
//        $('#grid').datagrid({
//            nowrap: false,
//            striped: true,
//            singleSelect: true,
//            collapsible: true,
//            url: 'OrderList.aspx?para=GetList&startIndex=' + 0 + "&Time1=" + time1 + "&Time2=" + time2+"&JF="+jf+"&st="+text+"&dz="+dz+"&dy="+dy,
//            sortName: 'ID',
//            sortOrder: 'asc',
//            idField: 'ID',
//            height: 'auto',
//            pageList: [5, 10, 20],
//            pageSize: 20,
//            fitColumns: true,
//            columns: [[
//        					{ field: 'ID', title: 'id', width: 200, sortable: true },
//                            { field: 'Name', title: '姓名', width: 200, sortable: true },
//                            { field: 'Phone', title: '电话', width: 200 },
//                             { field: 'SHR', title: '收货人', width: 200 },
//                              { field: 'SHRLXDH', title: '收货人联系电话', width: 200 },
//                            { field: 'SHDZ', title: '收货地址', width: 200 },
//                            { field: 'gname', title: '商品', width: 200 },
//                            { field: 'CreateDate', title: '下单时间', width: 200 },
//                            { field: 'States', title: '状态', width: 200 }
//        				]],
//            pagination: true,
//            rownumbers: true,
//            onHeaderContextMenu: function (e, field) {
//                e.preventDefault();
//                if (!$('#tmenu').length) {
//                    createColumnMenu("grid");
//                }
//                $('#tmenu').menu('show', {
//                    left: e.pageX,
//                    top: e.pageY
//                });
//            },
//            onRowContextMenu: function (e, rowIndex, rowData) {
//                if ($.trim(rowData.ID) == "") {
//                    var aa = $("#mm div");
//                    for (var a = 0; a < aa.length; a++) {
//                        var item = aa[a];
//                        if (item.innerText == "修改" || item.innerText == "删除") {
//                            $(item).css({ display: "none" });
//                            $(item).parent().css({ display: "none" });
//                        }
//                    }
//                }
//                selectRow = rowData;
//                e.preventDefault();
//                $(this).datagrid('unselectAll');
//                $(this).datagrid('getRows', rowData.code);
//                $('#mm').menu('show', {
//                    left: e.pageX,
//                    top: e.pageY
//                });
//            }
//        });
    }
</script>

